﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;

namespace ET.Monitor.DAL
{
    public class ConfigrationDAL
    {
        object objJudge = null;
        int intCount = 0;

        string strSql = "", strErrMsg = "";
        DataTable dtTable = new DataTable();
        DataSet dsChart = new DataSet();

        InvokeWebService iw = new InvokeWebService();
        string rtdbRelationAddress = "";
        string rtdbRealTimeAddress = "";
        string rtdbNameSpace = "";

        public ConfigrationDAL()
        {
            rtdbRelationAddress = ConfigurationManager.ConnectionStrings["RelationURL"].ConnectionString;
            rtdbRealTimeAddress = ConfigurationManager.ConnectionStrings["RealTimeURL"].ConnectionString;
            rtdbNameSpace = ConfigurationManager.ConnectionStrings["NameSpace"].ConnectionString;
        }

        #region 获取组态信息
        public DataTable GetConfigrationById(string id)
        {
            strSql = "select g.T_CONTROLID,g.T_CONTROLTYPE,g.T_TAG,c.T_RESULT,c.T_FORMULA From T_INFO_GRAPHIC g left join T_INFO_CONTROL c on g.T_CONTROLTYPE=c.T_CONTROLTYPE where g.T_GRAPHICID='" + id + "'";

            dtTable = (DataTable)iw.RunWebService(rtdbRelationAddress, rtdbNameSpace, "RunDataTable", new object[] { strSql, strErrMsg });

            return dtTable;
        }
        #endregion

        #region 获取组态信息
        public DataTable GetConfigrationControlById(string id)
        {
            strSql = "select T_CONTROLID,T_CONTROLTYPE From T_INFO_GRAPHIC where T_GRAPHICID='" + id + "'";

            dtTable = (DataTable)iw.RunWebService(rtdbRelationAddress, rtdbNameSpace, "RunDataTable", new object[] { strSql, strErrMsg });

            return dtTable;
        }
        #endregion
    }
}
